@extends('layouts.back_stage')
@section('style')
    @parent
    <style>
        .flow_head_box{
            width:100%;
            height:60px;
            border-bottom: 1px solid #cccccc;
        }
        .repertory_box{
            overflow: hidden;
            border-left:1px solid black;
            border-right:1px solid black;
            border-bottom:1px solid black;
            width:70%;
            margin:10px auto;
        }
        .repertory_box li{
            display: block;
            border-top:1px solid black;
            float:none;
            overflow: hidden;
        }
        .repertory_box dl{
            display: block;
            float:none;
        }
        .repertory_box dd{
            float:left;
            border-right:1px solid black;
            height:40px;
            text-align: center;
            line-height:40px;
        }
        .repertory_box dl dd:last-child{
            border-right:none;
        }
        .when_is_nothing{
            width:70%;
            height:452px;
            margin:10px auto;
            text-align: center;
            line-height: 452px;
            font-size:21px;
        }
    </style>
@endsection
@section('content')
<div class="container">
    <div style="padding: 20px 0;"><h3 >出库汇总查询</h3></div>
    <div class="flow_head_box">
        <label>款号：</label>
        @if(isset($_GET['girard']))
        <input type="text" style="width: 150px;display: inline-block;" name="girard" value="{{ $_GET['girard'] }}"  class="form-control girard" placeholder="输入款号">
        @else
            <input type="text" style="width: 150px;display: inline-block;" name="girard"  class="form-control girard" placeholder="输入款号">
        @endif
        <button class="btn btn-info" style="margin-bottom:3px;" onclick="serach_repertory()">搜索</button>
    </div>
    @if(isset($colors) && $colors)
    <ul class="repertory_box">
        <li>
            <dl>
                <dd class="col-md-2">{{ $brand[$goods_info->brand] }}/款号</dd>
                <dd class="col-md-10">{{ $goods_info->item }}</dd>
            </dl>
        </li>
        <li>
            <dl>
                <dd class="col-md-2">颜色</dd>
                @foreach( $total_count as $k=>$v)
                <dd class="col-md-1">{{ $k }}</dd>
                @endforeach
            </dl>
        </li>
        <li>
            <dl>
                <dd class="col-md-2">原库存</dd>
                @foreach( $total_count as $k=>$v)
                <dd class="col-md-1">{{ $total_count[$k] }}</dd>
                @endforeach
            </dl>
        </li>
        @foreach($companys as $k=>$v)
        <li>
            <dl>
                <dd class="col-md-2">{{ $v->company_name }}</dd>
                @foreach( $total_count as $ks=>$vs)
                    <dd class="col-md-1">
                        <?php
                            if(isset($res[$ks][$v->id]))
                                {
                                    echo $res[$ks][$v->id];
                                }else{
                                echo 0;
                            }
                        ?>
                    </dd>
                @endforeach
            </dl>
        </li>
        @endforeach
        <li>
            <dl>
                <dd class="col-md-2">剩余库存</dd>
                @foreach( $total_count as $k=>$v)
                    @if(isset($count[$k]))
                        <dd class="col-md-1">{{ $v - $count[$k] }}</dd>
                    @else
                        <dd class="col-md-1">{{ $v }}</dd>
                    @endif

                @endforeach
            </dl>
        </li>
    </ul>
    @else
            @if(isset($_GET['girard']))
            <p class="when_is_nothing">没有该款号</p>
            @else
            <p class="when_is_nothing">请输入需要查询的款号</p>
            @endif
    @endif
</div>
<script type="text/javascript">
    function serach_repertory(){
        var girard = $('.girard').val();
        if(girard != ""){
            window.location.href='/admin/goods_repertory?girard='+girard
        }else{
            $(".faceImg").attr("src","/img/weep.png");
            $(".oHandle").text("款号不能为空");
            $(".oSuccess").show(0).delay(1000).hide(0);
            return false;
        }

    }
</script>

@endsection
@section('style')
    @parent
    <link href="{{env('CDN_DOMAIN_NAME')}}/css/style.css?v=4.1.0" rel="stylesheet">
@endsection
@section('script')
    @parent
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/moment.js" type="text/javascript"></script>
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/daterangepicker.js" type="text/javascript"></script>
@endsection